<?php

namespace App\Model;

class Menu extends Model
{
    protected ?string $table = 'menus';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected array $fillable = ['id', 'pid', 'name', 'title', 'icon', 'path', 'component', 'is_cache', 'sort', 'created_at', 'updated_at', 'deleted_at'];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected array $casts = [
        'id' => 'integer',
        'pid' => 'integer',
        'sort' => 'integer',
        'is_cache' => 'integer',
        'created_at' => 'datetime',
        'updated_at' => 'datetime'
    ];
    /**
     * 设置name 属性.
     * @param $value
     */
    public function setNameAttribute($value)
    {
        $this->attributes['name'] = ucfirst($value);
    }
}